import net.optix.ip.events.ChangePasswordEvent;
        	import com.adobe.cairngorm.control.CairngormEventDispatcher;
        	import net.optix.ip.vo.ChangePasswordVO; 
        	import net.optix.ip.model.ModelLocator;
        	
            import mx.events.CloseEvent; 
            import mx.managers.PopUpManager;
            import mx.events.ValidationResultEvent;
            
            [Bindable]
            public var model:ModelLocator	=	ModelLocator.getInstance(); 
  			
  			public function init():void
  			{
  				model.bSubmit	=	true;
  				model.result	=	"";
  				model.close		=	"no";	
  			}
  			
            private function titleWindow_close(evt:CloseEvent):void { 
            	model.result	=	"";
            	model.bSubmit	=	true;
                PopUpManager.removePopUp(this); 
            }
            
            public function changePassword():void
            {	
            	var result:Boolean	=	true;

				var resultValidate:ValidationResultEvent;
				
				resultOldPassword.text		=	"";
				resultNewPassword.text		=	"";
				resultRetryPassword.text	=	"";
				model.result			=	"";
				
				stringValidator.minLength	=	6;
				resultValidate	=	stringValidator.validate(oldPassword.text);
            	if(resultValidate.type == ValidationResultEvent.INVALID)
            	{
            		result	=	false;
            		resultOldPassword.text	=	
            			resultValidate.message;
            	}
            	
            	stringValidator.minLength	=	6;
            	resultValidate	=	stringValidator.validate(newPassword.text);
            	if(resultValidate.type == ValidationResultEvent.INVALID)
            	{
            		result	=	false;
            		resultNewPassword.text	=	
            			resultValidate.message;
            	}
            	
            	if(retryNewPassword.text != newPassword.text)
            	{
            		resultRetryPassword.text	=	"It is not same as password";
            		result	=	false;
            	}
            	
            	model.bSubmit	=	false;
            	model.result	=	"";
            	
            	if(result == true)
            	{
            		var vo:ChangePasswordVO	=	new	ChangePasswordVO();
            		vo.userID		=	model.user.userID;
            		vo.oldPassword	=	oldPassword.text;
            		vo.newPassword	=	newPassword.text;
            		
            		var event:ChangePasswordEvent	=	new ChangePasswordEvent(vo);
	            	CairngormEventDispatcher.getInstance().dispatchEvent( event );
            	}
            	else
            	{
            		model.bSubmit	=	true;
            	}
            }
            
            public function clear():void
            {
            	
            }